//
//  GHPartnerDetailViewController.m
//  GodHorses
//
//  Created by Mac on 2017/11/18.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "GHPartnerDetailViewController.h"
#import "NSString+STFormatter.h"
@interface GHPartnerDetailViewController ()

@end

@implementation GHPartnerDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.frame = CGRectMake(0, 0, UIScreenWidth, UIScreenHeight - 64);
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.title = self.model.shop_name;
    [self configSubView];
    // Do any additional setup after loading the view.
}
#pragma mark --subView
- (void)configSubView{
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 300)];
    header.backgroundColor = [UIColor whiteColor];
    
    UIImageView * logoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 20, 150, 150)];
    [logoImageView sd_setImageWithURL:[NSURL URLWithString:self.model.logo] placeholderImage:GH_placeHoderImage];
    logoImageView.centerX = UIScreenWidth / 2;
    [header addSubview:logoImageView];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(0, logoImageView.st_bottom + 10, 300, 16)
                                                     text:self.model.company_name
                                                textColor:GH_firstTextColor
                                                     font:15
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentCenter];
    titleLable.centerX = UIScreenWidth / 2;
    [header addSubview:titleLable];
    
    //数组图片
    NSArray * images = [self.model.photo componentsSeparatedByString:@","];
    CGFloat imageTop = titleLable.st_bottom + 10;
    CGFloat imageHeight = UIScreenWidth - 20;
    for (int i = 0; i < images.count; i++) {
        UIImageView * tempView = [[UIImageView alloc] initWithFrame:CGRectMake(10, imageTop, UIScreenWidth - 20, imageHeight)];
        [tempView sd_setImageWithURL:images[i] placeholderImage:GH_placeHoderImage];
        [header addSubview:tempView];
        imageTop = imageTop + imageHeight + 5;
    }
    
    STLabel * contaceLable = [[STLabel alloc] initWithFrame:CGRectMake(10, imageTop + 10, UIScreenWidth - 20, 16)
                                                       text:[NSString stringWithFormat:@"联系人:%@",self.model.name]
                                                textColor:GH_firstTextColor
                                                     font:15
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [header addSubview:contaceLable];
    
    STLabel * phoneLable = [[STLabel alloc] initWithFrame:CGRectMake(10, contaceLable.st_bottom + 3, UIScreenWidth - 20, 16)
                                                       text:[NSString stringWithFormat:@"电话号码:%@",self.model.shop_phone]
                                                  textColor:GH_firstTextColor
                                                       font:15
                                                isSizetoFit:NO
                                              textAlignment:NSTextAlignmentLeft];
    [header addSubview:phoneLable];
    
    STLabel * addLable = [[STLabel alloc] initWithFrame:CGRectMake(10, phoneLable.st_bottom + 3, UIScreenWidth - 20, 16)
                                                     text:[NSString stringWithFormat:@"地址:%@%@%@%@",
                                                           self.model.addr_s,
                                                           self.model.addr_c,
                                                           self.model.addr_d,
                                                           self.model.addr_info]
                                                textColor:GH_firstTextColor
                                                     font:15
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [header addSubview:addLable];
    
    [NSString lableAutoAdjustheightWithLabel:addLable];
    
    header.height = addLable.st_bottom + 3;
    
    self.tableView.tableHeaderView = header;
}

#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 0;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        
    }
    cell.textLabel.textColor = UIColorFromRGBA(0x333333);
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.detailTextLabel.font = [UIFont systemFontOfSize:13];
    cell.detailTextLabel.textColor = UIColorFromRGBA(0x999999);
    
    cell.textLabel.text = [NSString stringWithFormat:@"%lu",indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}

@end
